﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TianShu.SysParameterSetting.Service.Abstracts;
using TianShu.SysParameterSetting.Service.Abstracts.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using TianShu.WebApi;

namespace TianShu.SysParameterSetting.WebApi.Controllers
{
    public class SysParameterSettingController : TianShuCrudController<Guid, SystemParameterSettingListOutput, SystemParameterSettingCreateUpdateInput>
    {
        ISystemParameterSettingService _sysParameterSettingService;
        public SysParameterSettingController(ISystemParameterSettingService sysParameterSettingService) : base(sysParameterSettingService)
        {
            _sysParameterSettingService = sysParameterSettingService;
        }

        /// <summary>
        /// 根据code获取参数
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        [HttpGet("get_by_code")]
        public async Task<IActionResult> GetByCode(string code)
        {
            var result =await _sysParameterSettingService.GetValue<string>(code);
            return Json(new ResultDto<object>((object)result));
        }
    }
}
